package com.xinqi.modules.sys.stats.controller.app;


import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.sys.stats.dto.req.SchoolTeachingDayStCreateDTO;
import com.xinqi.modules.sys.stats.dto.req.SchoolTeachingDayStQueryDTO;
import com.xinqi.modules.sys.stats.dto.req.SchoolTeachingDayStUpdateDTO;
import com.xinqi.modules.sys.stats.dto.rsp.SchoolTeachingDayStResultDTO;
import com.xinqi.modules.sys.stats.service.SchoolTeachingDayStService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 学校教学数据统计APP控制层
 *
 * @author: wenjie
 * @date: 2023/08/24
 */
@Tag(name = "school-teaching-day-st-App", description = "学校教学数据统计App接口")
@RestController
@RequestMapping("/app/school-teaching-day-st")
@RequiredArgsConstructor
public class SchoolTeachingDayStAppController {
    private final SchoolTeachingDayStService schoolTeachingDayStService;

    /**
     * 学校教学数据统计-分页
     */
    @Operation(summary = "学校教学数据统计-分页")
    @GetMapping("/page")
    public R<PageInfo<SchoolTeachingDayStResultDTO>> page(@ParameterObject SchoolTeachingDayStQueryDTO dto) {
        PageInfo<SchoolTeachingDayStResultDTO> page = schoolTeachingDayStService.page(dto, dto);
        return R.data(page);
    }

    /**
     * 学校教学数据统计-详情
     */
    @Operation(summary = "学校教学数据统计-详情")
    @GetMapping("/{id}")
    public R<SchoolTeachingDayStResultDTO> findById(@PathVariable("id") Long id) {
        SchoolTeachingDayStResultDTO dto = schoolTeachingDayStService.findById(id);
        return R.data(dto);
    }

    /**
     * 新增学校教学数据统计
     */
    @Operation(summary = "新增学校教学数据统计")
    @PostMapping
    public R<Long> insert(@RequestBody SchoolTeachingDayStCreateDTO dto) {
        return R.data(schoolTeachingDayStService.insert(dto));
    }

    /**
     * 修改学校教学数据统计
     */
    @Operation(summary = "修改学校教学数据统计")
    @PutMapping("/{id}")
    public R<Boolean> update(@PathVariable("id") Long id, @RequestBody SchoolTeachingDayStUpdateDTO dto) {
        dto.setId(id);
        return R.data(schoolTeachingDayStService.updateById(dto));
    }

    /**
     * 删除学校教学数据统计
     */
    @Operation(summary = "删除学校教学数据统计")
    @DeleteMapping("/{id}")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.data(schoolTeachingDayStService.deleteById(id));
    }

}
